<template>
  <div class="page">
    <div class="s-search p20">
      <el-form
        :model="alone.searchForm.data"
        status-icon
        ref="ruleForm"
        :inline="true"
        class="demo-ruleForm"
      >
        <el-form-item>
          <el-input
            placeholder="请输入主播昵称搜索"
            v-model="alone.searchForm.data.searchStr"
          >
          </el-input>
        </el-form-item>
        <!-- <el-form-item>
          <el-cascader
            placeholder="请选择部门"
            v-model="alone.searchForm.data.departmentIds"
            :props="orgCascaderCp.config.props"
            :options="orgSupAjax.data"
          >
          </el-cascader>
        </el-form-item> -->
        <el-form-item>
          <el-button type="primary" @click="rSubmitSearchForm">搜索</el-button>
        </el-form-item>
      </el-form>
    </div>

    <div class="c-main p20">
      <div class="clearfix">
        <div class="fl" style="line-height: 36px;">
          部门总成本：{{ pageAjax.paging.total }}
        </div>
        <div class="fl ml20" style="line-height: 36px;">单位：元</div>
        <div class="fl ml20" style="line-height: 36px;">
          刷新时间：{{ pageAjax.paging.total }}
        </div>
        <el-button type="text" class="fl ml20">刷新</el-button>
      </div>
      <div class="c-section">
        <div class="c-body">
          <div class="mt20">
            <b>成本详情</b> <span class="ml20">单位：元</span>
          </div>
          <el-row class="mt20">
            <el-col :span="20">
              <span>刷币申请总额:1000</span>
              <span class="ml20">已核销:1000</span>
              <span class="ml20">未核销:1000</span>
              <span class="ml20">刷币损失:1000</span>
            </el-col>
            <el-col :span="4">
              <router-link :to="{ name: 'agent_financePersonalRewardList' }"
                >详情</router-link
              >
            </el-col>
          </el-row>
          <el-row class="mt20">
            <el-col :span="20">
              <span>主播保底/底薪总额:1000</span>
            </el-col>
            <el-col :span="4">
              <router-link :to="{ name: 'agent_financePersonalBasePayDetail' }"
                >详情</router-link
              >
            </el-col>
          </el-row>
          <el-row class="mt20">
            <el-col :span="20">
              <span>签约金总额:1000</span>
            </el-col>
            <el-col :span="4">
              <router-link :to="{ name: 'agent_financePersonalRetainerDetail' }"
                >详情</router-link
              >
            </el-col>
          </el-row>
          <el-row class="mt20">
            <el-col :span="20">
              <span>设备扶持费用总额:1000</span>
            </el-col>
            <el-col :span="4">
              <router-link
                :to="{ name: 'agent_financePersonalFacilityCostDetail' }"
                >详情</router-link
              >
            </el-col>
          </el-row>
          <el-row class="mt20">
            <el-col :span="20">
              <span>住房扶持费用总额:1000</span>
            </el-col>
            <el-col :span="4">
              <router-link
                :to="{ name: 'agent_financePersonalHouseCostDetail' }"
                >详情</router-link
              >
            </el-col>
          </el-row>
          <el-row class="mt20">
            <el-col :span="20">
              <span>经纪权转让费用总额:1000</span>
            </el-col>
            <el-col :span="4">
              <router-link
                :to="{ name: 'agent_financePersonalClosingCostDetail' }"
                >详情</router-link
              >
            </el-col>
          </el-row>
          <el-row class="mt20">
            <el-col :span="20">
              <span>星探合作费用总额:1000</span>
            </el-col>
            <el-col :span="4">
              <router-link
                :to="{ name: 'agent_financePersonalSeestarCostDetail' }"
                >详情</router-link
              >
            </el-col>
          </el-row>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { getBiPlatformList } from "@/api/others.js";
import { getActorList, cancelBindActor } from "@/api/actor.js";
import { mixin } from "@/components/mixin/getSalaryStr.js";
import _ from "lodash";
import { getOffspringnTree } from "@/assets/js/util.js";

export default {
  name: "agent_signedList",
  mixins: [mixin],
  data: () => ({
    pageAjax: {
      btnDisabled: false,
      btnLoading: false,
      loading: false,
      lock: false,
      paging: {
        pages: 1, // 总页数
        current: 0, // 当前页
        total: 1, // 总数量
        pageSize: 10 // 每页数量
      },
      data: []
    },
    biPlatformListSupAjax: {
      data: []
    },
    orgSupAjax: {
      data: []
    },
    alone: {
      signStatus: "SIGNED",
      searchForm: {
        loading: false,
        data: {
          departmentIds: [],
          searchStr: "",
          tenantType: "3",
          relType: 2
        }
      }
    },
    translate: {
      biPlatformList: {}
    },
    orgCascaderCp: {
      config: {
        props: {
          value: "id",
          label: "name",
          multiple: true,
          emitPath: false,
          checkStrictly: true
        }
      }
    }
  }),
  created() {
    let _that = this;
    _that.getBiPlatformListData().then(() => {
      _that.getPageData();
      _that.getOrgData();
    });
  },
  mounted() {},
  methods: {
    rSubmitSearchForm() {
      let _that = this;
      if (_that.pageAjax.loading) {
        return;
      }
      _that.pageAjax.lock = false;
      _that.pageAjax.paging.current = 0;
      // if (!searchForm.data.searchStr && !searchForm.data.signWish && !searchForm.data.platform) {
      //   _that.$message.error({message: "搜索条件不能都为空", onClose: () => {
      //     _that.alone.searchForm.loading = false;
      //   }});
      //   return;
      // }
      _that.pageAjax.lock = false;
      _that.pageAjax.paging.current = 0;
      _that.getPageData();
    },
    rPagingChange(e) {
      let _that = this;
      _that.pageAjax.paging.current = e - 1;
      _that.getPageData();
    },
    getBiPlatformListData() {
      let _that = this;
      return getBiPlatformList()
        .then(resp => {
          let respData = resp.data || {};

          if (respData.code === _that.STATUS.success[0]) {
            let translate = {};
            let arr = respData.data.filter(item => {
              if (item.value != "all") {
                translate[item.value] = item.name;
                return item;
              }
            });
            _that.biPlatformListSupAjax.data = arr;
            _that.translate.biPlatformList = translate;
          } else {
            _that.$message.error(respData.msg || "获取失败");
          }
        })
        .finally(() => {});
    },
    getPageData() {
      let _that = this;
      let searchForm = _.cloneDeep(_that.alone.searchForm);
      let pageAjax = _that.pageAjax;

      if (pageAjax.loading || pageAjax.lock) {
        return;
      }

      let data = { ...searchForm.data };
      data.pageNo = _that.pageAjax.paging.current + 1;
      data.signStatus = _that.alone.signStatus;
      _that.pageAjax.loading = true;
      getActorList({ params: data })
        .then(resp => {
          let respData = resp.data || {};

          if (respData.code === _that.STATUS.success[0]) {
            _that.pageAjax.data = respData.data.list;
            _that.pageAjax.paging = {
              pages: respData.data.pagination.pages,
              current: respData.data.pagination.current,
              total: respData.data.pagination.total,
              pageSize: respData.data.pagination.pageSize
            };
          } else {
            _that.$message.error(respData.msg || "获取失败");
          }
        })
        .finally(() => {
          _that.pageAjax.loading = false;
        });
    },
    getOrgData() {
      let _that = this;
      _that.$store.dispatch("getDepartmentList").then(() => {
        let arr = _.cloneDeep(_that.$store.state.departmentList) || [];
        _that.orgSupAjax.data = getOffspringnTree(_.cloneDeep(arr), 0);
      });
    },
    rAgentReleaseActor(id) {
      let _that = this;
      console.log(id, _that);
      this.$confirm("你确定要释放此主播?", "释放主播提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          cancelBindActor({ anchorId: id }).then(resp => {
            let respData = resp.data || {};
            if (respData.code === _that.STATUS.success[0]) {
              _that.$message.success(respData.msg || "绑定成功");
              _that.pageAjax.paging.current =
                _that.pageAjax.paging.current > 0
                  ? _that.pageAjax.paging.current - 1
                  : 0;
              _that.getPageData();
            } else {
              _that.$message.error(respData.msg || "绑定失败");
            }
          });
        })
        .catch(() => {});
    },
    navToDetail(id) {
      this.$router.push({
        name: "agent_detail",
        query: {
          anchorId: id
        }
      });
    },
    navToLiveDetail(id) {
      this.$router.push({
        name: "agent_liveDetail",
        query: {
          anchorId: id
        }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.page {
  .s-search {
    border-bottom: 1px solid #eee;
  }
  .c-aside {
    .btn {
      margin-right: 20px;
    }
    .diy-uploadBtn {
      margin-right: 20px;
    }
  }
  .c-main {
    margin-top: 20px;
    .c-avatar {
      display: block;
      width: 100px;
      height: 100px;
      border-radius: 50%;
    }
  }
  .c-pagination {
    margin-top: 20px;
    text-align: center;
  }
  .f-agentWish {
    overflow: hidden;
    position: absolute;
    width: 100%;
    left: 0;
    top: 0;
    bottom: 0;
    .c-content {
      height: 100%;
      padding-bottom: 20px;
      overflow: auto;
    }
    .c-card {
      .c-item {
        padding-bottom: 20px;
        border-top: 1px solid #f5f7fa;
      }
      .c-UserInfo {
        position: relative;
        overflow: hidden;
        line-height: 25px;
      }
      .c-avatar {
        float: left;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        overflow: hidden;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .c-nameInfo {
        float: left;
        margin-left: 20px;
      }
      .c-copyBtn {
        cursor: pointer;
        position: absolute;
        right: 0;
        top: 0;
        border: 1px solid #eee;
        padding: 10px 20px;
        border-radius: 20px;
      }
      .c-bid {
        overflow: hidden;
        line-height: 30px;
        img {
          float: left;
          width: 30px;
          height: 30px;
          margin-right: 20px;
        }
      }
    }
  }
  .f-agent {
    overflow: hidden;
    position: absolute;
    width: 100%;
    left: 0;
    top: 0;
    bottom: 0;
    .c-content {
      height: 100%;
      padding-bottom: 20px;
      padding-top: 60px;
      overflow: auto;
    }
    .c-avatar {
      width: 80px;
      height: 80px;
    }
  }
}
</style>
<style lang="scss">
.page {
  .el-drawer__header {
    position: relative;
    z-index: 10;
  }
}
</style>
